//
//  UIView+WSDraw.m
//  SleepingElf
//
//  Created by karong on 2023/6/15.

#import "UIView+WSDraw.h"

@implementation UIView (WSDraw)

- (void)realSetupRoundedCornersWithCutCorners:(UIRectCorner)rectCorner withRadii:(CGSize)radii {
    UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:rectCorner cornerRadii:radii];
    CAShapeLayer* shape = [[CAShapeLayer alloc] init];
    [shape setPath:rounded.CGPath];
    self.layer.mask = shape;
}


- (void)setupRoundedCornersWithCutCorners:(UIRectCorner)rectCorner withRadii:(CGSize)radii {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:rectCorner cornerRadii:radii];
        CAShapeLayer* shape = [[CAShapeLayer alloc] init];
        [shape setPath:rounded.CGPath];
        self.layer.mask = shape;
    });
}


@end
